package com.yyh.xiancheng;
/*线程*/
public class Demo1 {
    public static void main(String[] args) {
        //创建线程对象
        MyThread t1 = new MyThread();
        t1.setName("线程1");
        //启动线程,调用start方法启动线程
        t1.start();
        MyThread t2 = new MyThread();
        t2.setName("线程2");
        t2.start();
        MyThread t3 = new MyThread();
        t3.setName("线程3");
        t3.start();
    }
}
//创建子类继承Thread类
class MyThread extends Thread{
    //重写run方法
    @Override
    public void run() {
        for (int i = 1; i <= 100; i++) {
            System.out.println(Thread.currentThread().getName()+"：" + i);
        }
    }
}
